package org.jetnuke.blocks;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IBlock;
import org.jetnuke.common.IBlockInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.DataAccessDriver;


public class BigStoryOfToday implements IBlock {

	public void serviceBlock(HttpServletRequest req, VelocityContext vc,
			IBlockInfo blockInfo, IUserInfo userInfo, IAdminInfo adminInfo)
			throws Exception {
		//Criteria crt = new Criteria();
		GregorianCalendar gc = new GregorianCalendar();
		gc.set(Calendar.HOUR_OF_DAY, 0);
		gc.set(Calendar.MINUTE, 0);
		gc.set(Calendar.SECOND, 0);
		gc.set(Calendar.MILLISECOND, 0);
		List ls =DataAccessDriver.getInst().newStoriesDAO().getStoriesGreaterTime(gc.getTime()); 
			
//			storiesPeer.doSelect(crt.add(storiesPeer.TIME, gc.getTime(),
				//Criteria.GREATER_EQUAL).addDescendingOrderByColumn(
					//	storiesPeer.COUNTER).setLimit(1));
		if (!ls.isEmpty())
			vc.put("big", ls.get(0));
	}

}
